#include <iostream>
#include <vector>
#include <set>
using namespace std;

class Solution1 {
public:
    int minimumLevels(vector<int>& possible) {
        int sum = 0;
        for (int& p : possible)
        {
            if (p == 0) p = -1;
            sum += p;
        }

        int n = possible.size(); int cur = 0;
        for (int i = 0; i < n - 1; ++i)
        {
            cur += possible[i];
            if (cur > sum - cur)
                return i + 1;
        }

        return -1;
    }
};

bool check(int num)
{
    for (int i = 2; i <= num / i; ++i)
        if (num % i == 0)
            return false;
    return true;
}

class Solution2 {
public:
    int countKConstraintSubstrings(string s, int k) {
        int res = 0, left = 0;
        int cnt[2] = { 0 };
        for (int i = 0; i < s.size(); ++i)
        {
            cnt[s[i] & 1]++;
            while (cnt[0] > k && cnt[1] > k)
            {
                cnt[s[left] & 1]--;
                left++;
            }
            res += i - left + 1;
        }
        return res;
    }
};

class Solution3 {
public:
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        vector<int> nums;
        int p1 = 0, p2 = 0;
        while (p1 < m && p2 < n)
        {
            if (nums1[p1] < nums2[p2])
                nums.push_back(nums1[p1++]);
            else
                nums.push_back(nums2[p2++]);
        }
        while (p1 < m) nums.push_back(nums1[p1++]);
        while (p2 < n) nums.push_back(nums2[p2++]);
        swap(nums1, nums);
    }
};

int main()
{
    vector<int> nums;
    for (int i = 2; i <= 1000; ++i)
        if (check(i)) nums.push_back(i);

    int n; cin >> n;
    set<int> st;
    for (int i = 0; i < n; ++i)
    {
        int ai; cin >> ai;
        for (int num : nums)
        {
            if (num > ai) break;
            if (ai % num == 0) st.insert(num);
        }
        if (st.size() >= 5) break;
    }
    if (st.size() < 5)
    {
        cout << -1;
        return 0;
    }
    int res = 0; int cnt = 0;
    for (auto num : st)
    {
        res += num;
        if (++cnt == 5) break;
    }
    cout << res;
    return 0;
}
